package com.sss.hloster07;

public class InsertSort {         // 直接插入排序
	public InsertSort(int a[]) {
		int temp = 0;
		for (int i = 0; i < a.length; i++) {
			int j = i - 1;
			temp = a[i];
			for (; j >= 0 && temp < a[j]; j--) {
				a[j + 1] = a[j];// 将大于temp的值整体后移一个单位
			}
			a[j + 1] = temp;
		}
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + "     ");
		}
	}
	
}
